<template>
  <div class="web-container info">
    <div class="content">
      <div class="content-left">
        <div class="content-top">
          <img class="content-cover" :src="'http://c61.cnki.net/CJFD/big/'+cover+'.jpg'" alt="">
          <div class="content-top-right">
            <span class="content-title" v-html="bookName"></span>
            <span class="content-author" v-html="'第'+$route.query.period+'期'"></span>
            <span class="content-press">出版社:机械工业出版社</span>
            <span class="content-year">出版年:2018年8月</span>
            <span class="content-read">124567人在读</span>
            <div class="content-btn">
              <el-button type="primary" round @click="goToContent">阅&nbsp;读</el-button>
              <!-- <ul>
                <li><i class="iconfont icon-shoucang"></i>收藏</li>
                <li><i class="iconfont icon-fenxiang"></i>分享</li>
              </ul> -->
            </div>
          </div>
        </div>
        <div class="content-bottom">
          <span class="title">往期</span>
          <div class="desc">
            <span v-for="(item,index) in classList" :key="index" class="item" v-html="item.external_source_name" @click="setNewBook(item)" :class="item.external_source_id===newBook.external_source_id?'border-green':''">2018年第17期</span>
          </div>
        </div>
      </div>
      <div class="content-right">
         <div class="read-box">
          <el-tabs v-model="activeName2" type="card">
            <el-tab-pane label="移动端阅读" name="first">
              <span class="scan">
                <img src="/static/images/base/code.jpg" style="width: 135px;" alt="">
              </span>
              <span class="scan">扫描二维码</span>
            </el-tab-pane>
            <el-tab-pane label="关注公众号" name="second">
              <span class="scan">
                <img src="/static/images/base/code.jpg" style="width: 135px;" alt="">
              </span>
              <span class="scan">扫描关注公众号</span>
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { GetperiodicalListList } from "../../api/Api";
import { readRecord } from "@/api/index";
import urls from "@/api/base";
export default {
  data() {
    return {
      classList: [],
      pageSize: 7,
      currentPage: 1,
      total: 0,
      newBook: {},
      bookName: "",
      cover: "",
      activeName2:"first"
    };
  },
  created() {
    this.cover = this.$route.query.max_file_name;
    this.bookName = this.$route.query.value;
    GetperiodicalListList(
      this.$route.query.resourceType,
      this.$route.query.value,
      this.$route.query.period,
      this.currentPage,
      this.pageSize
    ).then(result => {
      this.classList = result.data;
      this.newBook = result.data[0];
      console.log(this.classList, 123);
      this.total = result.total;
    });
  },
  components: {},
  methods: {
    goToContent() {
      console.log(this.newBook);
       readRecord(this.newBook.external_source_name,5,this.bookName,this.newBook.file_name,'','').then(res=>{
          console.log(res.data)
        })
         this.$router.push({
        name: "periodicalcontent",
        params: { url:urls.purl +this.newBook.file_name.substring(0, 10) +'/' +this.newBook.file_name +'.pdf' }
      });
    },
    setNewBook(item) {
      this.newBook = item;
      console.log(item);
    }
  }
};
</script>
<style lang="less" scoped>
.custom-dz{
  .info .content .content-left .content-bottom .title{
    color: #e93926;
  }
  .info .border-green{
    color: #e93926;
  }
  .info .content .content-right .read-box{
    background: #fff1ef;
  }
}
.info {
  .border-green {
    color: #15c798;
  }
  .content {
    min-height: 400px;
    background: #fff;
    border-radius: 10px;
    padding: 30px 128px;
    display: flex;
    .content-left {
      flex: 1;
      .content-top {
        display: flex;
        .content-cover {
          margin-bottom: 34px;
          width: 196px;
          height: 264px;
          border-radius: 10px;
          box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
        }
        .content-top-right {
          margin-left: 30px;
          height: 264px;
          display: flex;
          flex: 1;
          width: 100%;
          flex-direction: column;
          .content-btn {
            margin-top: 90px;
            display: flex;
            .el-button {
              // background-color: #15c798;
              line-height: 32px;
              width: 110px;
              font-size: 16px;
              padding: 0px 20px;
              border: 2px solid transparent;
              .el-button--primary:focus,
              .el-button--primary:hover {
                // background-color: #15c798;
              }
            }
            ul {
              padding-left: 0px;
              width: 100%;
              text-align: right;
              display: flex;
              justify-content: flex-end;
              li {
                // float: left;
                cursor: pointer;
                line-height: 42px;
                font-size: 16px;
                color: #808080;
                display: flex;
                align-items: center;
                padding: 0 15px;
                i {
                  font-size: 30px;
                  margin-right: 10px;
                }
              }
            }
          }

          .content-title {
            font-size: 24px;
            font-weight: bold;
          }
          .content-author,
          .content-press,
          .content-year,
          .content-read {
            font-size: 16px;
            color: #808080;
            margin-top: 5px;
          }
        }
      }
      .content-bottom {
        .title {
          display: block;
          padding: 15px 25px;
          font-size: 16px;
          color: #15c798;
          font-weight: bold;
          border-bottom: 1px solid #c1c1c1;
          position: relative;
        }
        .title::after {
          content: "";
          display: inline-block;
          width: 8px;
          height: 8px;
          background: #fff;
          border-top: 1px solid #c1c1c1;
          border-right: 1px solid #c1c1c1;
          transform: rotate(-45deg);
          position: absolute;
          bottom: -5px;
          left: 35px;
        }
        .desc {
          padding: 10px 0px 150px 0px;
          font-size: 16px;
          line-height: 30px;
          color: #a1a1a1;
          display: flex;
          flex-direction: column;
          .item {
            width: 690px;
            height: 36px;
            line-height: 36px;
            margin-bottom: 10px;
            border-bottom: 1px solid #c1c1c1;
            user-select: none;
            cursor: pointer;
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
          }
        }
      }
    }
    .content-right {
      width: 223px;
      margin-left: 30px;
      user-select: none;
      .read-box {
        width: 100%;
        border-radius: 10px;
        background: #ecfcf8;
        box-shadow: #e6e6e6 2px 2px 10px;
        .scan {
          display: block;
          text-align: center;
          font-size: 14px;
          padding: 6px 0;
          color: #808080;
        }
        .title {
          display: block;
          padding: 20px 0px 14px 20px;
          font-size: 18px;
          font-weight: bold;
          border-bottom: 1px solid #c8e2dc;
        }
        .code {
          margin-left: 52px;
        }
        .system {
          display: flex;
          justify-content: space-between;
          padding: 20px 45px;
          cursor: pointer;
          span {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: #15c798;
            img {
              margin-bottom: 10px;
            }
          }
        }
      }
    }
  }
}
</style>


